# !/usr/bin/env python
# -*- coding: utf-8 -*-

from handlers import content
from handlers import home
from handlers import mall
from handlers import mp
from handlers import pad_mall
from handlers.api import (
    partner,
    after_sale,
    pc,
    ad,
    reports,
    restaurant,
    activities,
    device_control,
    store,
    admin,
    gift,
    log,
    discover,
    dinner,
    user,
    order,
    goods,
)

handlers = [
    (r"/", home.PCMall),  # 主页
    (r"/home", home.Home),  # 主页
    (r"/auth", home.Auth),
    (r"/404", home.NotFoundHandler),
    (r"/error", home.ErrorHandler),
    (r"/success", home.SuccessHandler),
    (r"/MP_verify_tPrADLZPLfqpKcKG.txt", home.MPVerify1),  # 微信域名绑定验证 wx.style999.com
    (r"/MP_verify_xNu24Ee12jfHJcqH.txt", home.MPVerify2),  # 微信域名绑定验证 wx.laez.com.cn
    (r"/MP_verify_dK63Cq21Cd8PcFzm.txt", home.MPVerify3),  # 微信域名绑定验证 wx.laez9.com
    (r"/menu", home.WechatMenu),
    (r"/text/style999/access_token", home.AccessToken),
    (r"/test/jsticket", home.JSTicket),
    (r"/test/test", home.Test),
    # 微信公众号Media Platform
    (r"/mp/message/entry", mp.Entry),  # 消息入口
    (r"/mp/qrcode/id_scene", mp.QRScene),  # 屏端加载的二维码
    # 微信商城 (前后端不分离） ###########################################################
    (r"/mall", mall.Mall),
    (r"/mall/detail/(\w+)", mall.GoodsDetail),
    (r"/cart", mall.Cart),
    (r"/address_manage", mall.AddressManage),
    (r"/address", mall.Address),
    (r"/share", mall.Share),
    (r"/shared", mall.Shared),
    (r"/gift/application", gift.GiftApplication),  # 发送申领成功通知
    (r"/gift/(\S+)", mall.Gift),  # 送礼订单查看和填写收货地址页面
    (r"/order", mall.Order),
    (r"/order/(\w+)", home.Order),
    (r"/order/detail/(\w+)", mall.OrderDetail),
    (r"/payment/confirm", mall.PayConfirm),  # 下单付款
    (r"/payment/wechat_notify", mall.WechatNotify),  # 微信支付回调
    (r"/payment/received/(\d+)", mall.Received),  # 确认收货
    (r"/payment/auto_received/(\d+)", mall.AutoReceived),  # 发货7天后自动确认收货
    (r"/payment/income/(\d+)", mall.Income),  # 计算提成
    (r"/payment/refund", mall.Refund),  # 退款
    (r"/user/update/(\S+)", mall.UpdateUser),  # 更新用户信息
    (r"/user/bind/(\S+)", mall.BindUser),  # 绑定后台合伙人帐号
    (r"/user/invite/partner/(\d+)/(\S+)", mall.InvitePartner),  # 邀请合伙人
    (r"/user/promotion", mall.Promotion),  # 新用户活动中转
    (r"/content/subscribe", content.SubscribeHandler),  # 微信公众号绑定的内容
    (r"/go", mall.Go),  # 中转页跳转/go?url=跳转目标
    # 屏端商城
    (r"/pad/mall", pad_mall.Mall),
    (r"/pad/mall/detail/(\w+)", mall.GoodsDetail),
    (r"/pad/mall/switch/(\w+)", pad_mall.SwitchHandler),  # 中转页面
    (r"/pad/order", mall.Order),
    (r"/pad/payment/confirm", pad_mall.PayConfirm),  # 扫码支付
    # 中转页
    (r"/pc/mall", home.PCMall),  # PC商城
    (r"/wx/mall", home.Mall),  # 微信商城
    (r"/wx/store", home.Store),  # 线下门店
    (r"/wx/discover", home.Discover),  # 行家点评
    (r"/user/account", home.UserAccount),  # 用户账户信息
    (r"/wx/user/device", home.Device),  # 设备控制
    (r"/wx/user/poster", home.UserPoster),  # 我的海报
    (r"/wx/user/wine", home.MyWine),  # 我的存酒
    (r"/wx/winecard", home.WineCard),  # 我的酒卡
    (r"/wx/promotion", home.Promotion),  # 新店酬宾活动 领券海报中转页 20210308
    (r"/wx/shop_open_promo", home.PromotionPoster),  # 新店酬宾活动海报 领券海报中转页 20210312
    (r"/wx/coupon_buy", home.CouponBuy),  # 新店酬宾活动 领券抢购 20210309
    (r"/wx/aboutus", home.AboutUs),  # 关于我们
    (r"/wx/register/invite_partner", home.InvitePartner),  # 邀请合伙人注册二维码页中转
    (r"/wx/register/(\d+)/(\S+)", home.Register),  # 合伙人注册
    (r"/wx/template/message", home.TemplateMesage),  # 模板消息目标页面
    (r"/admin/partner", home.Partner),  # 合伙人管理后台
    (r"/qr/(\d+)", home.QR),  # 可变二维码
    (r"/g/(\d+)/(\w+)", home.GiftQR),  # 礼品订购可变二维码
    (r"/vip/(\d+)/(\w+)", home.VipQR),  # 员工卡
    (r"/v/(\d+)/(\w+)", home.Vip),  # 电子贵宾卡
    # 导购智慧屏商品链接
    (r"/goods/(\d+)", home.Goods),  # 商品导购中转页
    # 合伙人接口 ###################################################################
    (r"/api/partner/info", partner.UserInfo),  # 获取用户信息，废弃，改用 /api/user/info
    (r"/api/partner/qrcode", partner.QRCode),  # 获取自己的二维码，废弃，改用 /api/user/qrcode
    (r"/api/partner/finance/summary", partner.FinanceSummary),
    (r"/api/partner/finance/daily_stats", partner.FinanceDailyStats),
    (r"/api/partner/finance/detail", partner.FinanceDetail),
    (r"/api/partner/cash/detail", partner.CashDetail),  # 合伙人提现记录
    (r"/api/partner/cash/apply", partner.CashApplyHandler),  # 合伙人提现申请
    (r"/api/partner/team/info", partner.TeamInfo),  # 团队信息
    (r"/api/partner/user/invited_user", partner.InvitedUser),  # 邀请用户
    (
        r"/api/partner/user/invited_agency",
        partner.InvitedAgency,
    ),  # 邀请合伙人 0=初级，1=高级，2=事业部（及其他）
    (
        r"/api/v2/partner/user/invited_agency",
        partner.InvitedAgency2,
    ),  # 邀请合伙人(0=全部，1=合伙人（0/1）2=事业部(及其他）
    (r"/api/partner/register", partner.Register),  # 合伙人注册
    (r"/api/partner/new_register", partner.NewRegister),  # 新合伙人注册
    (r"/api/partner/expert_register", partner.ExpertRegister),  # 行家/商家/新事业合伙人注册
    (r"/api/partner/address", partner.UserAddress),  # 加盟费/众筹赠酒收货地址/499元注册
    (r"/api/partner/cash/bank_card", partner.BankCard),  # 添加/查看银行卡信息
    (r"/api/partner/update_bankcard", partner.UpdateBankCard),  # 合伙人提现银行卡信息修改接口
    (r"/api/partner/first_load", partner.FirstLoad),
    (r"/api/partner/daily_benefit", partner.DailyBenefitReturn),  # 众筹收益每日返还情况
    (r"/api/partner/benefit_times", partner.BenefitReturnTimes),  # 统计每日收益返还出错的众筹订单信息
    (r"/api/partner/funding_order", partner.CrowdFundingOrder),  # 查看所有众筹订单信息
    (
        r"/api/partner/recommend_detail",
        partner.RrecommenderBenefitDetail,
    ),  # 众筹订单推荐人每日奖励明细
    (r"/api/partner/error_order", partner.ErrorBenefitOrder),  # 众筹订单推荐人每日奖励出错的订单列表
    (r"/api/partner/is_subscribe", partner.IsSubscribe),  # 判断用户是否关注公众号
    (r"/api/partner/update_user", partner.UpdateUserInfo),  # 更新用户信息
    (r"/api/partner/login_date", partner.LoginDate),  # 判断合伙人进入后台的时间是否超过7天
    (r"/api/partner/benefit_ranking", partner.BenefitRanking),  # 合伙人直属收益当月/上月排名
    (r"/api/partner/upload_poster", partner.UploadPoster),  # 上传海报图片
    (r"/api/partner/save_poster", partner.SavePosterInfo),  # 保存海报图片信息到数据库
    (r"/api/partner/del_poster", partner.DelPoster),  # 删除海报
    (r"/api/partner/get_coupon", partner.GetCoupon),  # 领取餐券
    (r"/api/partner/use_coupon", partner.UseCoupon),  # 使用餐券
    (r"/api/partner/get/red_packet", partner.GetRedPacket),  # 领取红包
    (r"/api/partner/update_info", partner.UpdateInfo),  # 发卡商户注册 更新agency表中信息
    # API #####################################################################
    (r"/api/share", partner.Share),  # 微信分享
    # api/goods
    (r"/api/mall", goods.Mall),  # 商城接口
    (r"/api/detail/(\w+)", goods.GoodsDetail),  # 商品详情
    (r"/api/goods", goods.Goods),  # 商品列表
    (r"/api/goods/timestamp", goods.LastModified),  # 商品信息时间戳
    (r"/api/goods/(\w+)", goods.GoodsDetail),  # # 商品详情
    (r"/api/img_info", goods.ImageInfo),  # 商品图片
    # api/order
    (r"/api/cart", order.Cart),  # 购物车接口
    (r"/api/buy_part", order.BuyPartGoods),  # 选中购物车中部分商品购买
    (r"/api/order", order.Order),  # 订单列表
    (r"/api/order/detail/(\w+)", order.OrderDetail),  # 订单详情
    (
        r"/api/order/delivery_notification/(\d+)",
        order.OrderDeliveryNotification,
    ),  # 通知供应商发货
    (r"/api/order/shipped", order.OrderShipped),  # 订单确认发货
    (r"/api/modify_address", order.ModifyAddress),  # 修改地址
    (r"/api/address", order.Address),  # 用户添加地址接口
    (r"/api/address_manage", order.AddressManage),  # 商城地址列表
    (r"/api/payment/confirmation", order.PayConfirm),  # 订单确认
    (r"/api/balance/detail", order.BalanceDetail),  # 余额详情
    (r"/api/report/user", partner.ReportUser),  # 用户报告
    (r"/api/report/partner", partner.ReportPartner),  # 合伙人报告
    (r"/api/device/info", partner.DeviceInfo),  # 设备信息
    # api/user
    (r"/api/user/account_balance", partner.AccountBalance),  # 用户账户余额
    (r"/api/user/info", partner.UserInfo),  # 获取用户信息
    (r"/api/user/qrcode", partner.QRCode),  # 获取自己的二维码
    (r"/api/user/address", partner.UserAddress),  # 用户地址
    (r"/api/user/cart_nums", partner.CartGoodsNums),  # 购物车商品数量
    (r"/api/user/inventory", user.UserInventory),  # 用户存酒
    (r"/api/user/payconfirm", user.PayConfirm),  # 用户取酒
    (r"/api/user/scan_user", partner.ScanUserNumber),  # 餐厅扫码尾数为1或7的用户信息及人数
    (r"/api/user/cash/apply", user.UserCashApplyHandler),  # 普通用户可提现余额提现申请
    (r"/api/user/name", user.UserName),  # 用户实名（余额提现到微信）
    (r"/api/user/activity", user.Activity),  # 促销活动领券
    (r"/api/user/vip_card", user.VipCard),  # 员工卡
    (r"/api/after_sale/(\d+)", after_sale.AfterSale),  # 售后接口
    (r"/api/after_sale/(\d+)/status", after_sale.AfterSaleStatus),  # 售后状态接口
    # WEB API
    (r"/api/user/qrconnecturl", pc.QRConnectUrl),
    (r"/api/user/wx_login", pc.PCWxLogin),
    (r"/api/user/islogin", pc.CheckLogin),
    (r"/api/user/register", pc.PCRegister),
    (r"/api/user/phone_login", pc.PCPhoneLogin),
    (r"/api/user/logout", pc.PCLogout),
    (r"/api/goods", pc.Goods),
    (r"/api/pay/confirm", pc.PCPayConfirm),
    (r"/payment", pc.PCPayNotify),
    (r"/api/orderquery", pc.OrderQuery),
    # AD API
    (r"/api/ad/subscribe", ad.Advert),
    (r"/api/ad/track", ad.AdvertTrack),
    (r"/api/ad/statistics", ad.AdStatistics),  # 广告统计接口
    (r"/api/ad/register", ad.Register),
    (r"/api/ad/upload", ad.SourceUpload),  # 素材上传接口
    (r"/api/ad/person/center", ad.PersonCenter),  # 个人中心
    (r"/api/ad/list", ad.AdList),  # 广告列表接口
    (r"/api/ad/bill", ad.AdBill),  # 个人广告账单
    (r"/api/ad/add_ad", ad.AddAd),  # 添加广告接口
    (r"/api/ad/advert_list", ad.AdvertList),  # 查看广告接口
    (r"/api/ad/get_ad", ad.GetAd),  # 获取广告接口
    (r"/api/ad/filter_ad", ad.FilterAd),  # 添加禁播广告的设备
    (r"/api/ad/free_device", ad.FreeDevice),  # 解除设备广告禁播
    (r"/api/ad/is/owner_device", ad.IsOwnerDevice),  # 检查用户是否拥有对应设备
    (r"/api/ad/photo_album", ad.PhotoAlbum),  # 私人酒柜相册
    (r"/api/ad/random_play", ad.RandomPlay),  # 设置私人酒柜是否随机播放
    # REPORTS API
    (r"/api/reports/partnerinfo", reports.PartnerInfo),
    (r"/api/reports/download/scan_user", reports.DownloadScanUer),  # 下载餐厅扫码幸运用户信息
    (r"/api/reports/download/wait_order", reports.DownloadWaitExpressOrder),  # 下载待发货订单
    (r"/api/reports/download/partner_info", reports.DownloadPartnerInfo),  # 下载合伙人信息
    (r"/api/reports/download/qrcode", reports.DownloadQrcode),  # 下载自动生成的发卡人二维码
    (
        r"/api/reports/store/online_order_summary",
        reports.StoreUserOnlineOrders,
    ),  # 门店用户线上订单汇总报告
    # 合作餐厅信息录入接口
    (r"/api/restaurant/info", restaurant.RestaurantInfo),
    (r"/api/restaurant/delete_info", restaurant.DeleteRestaurantInfo),  # 合作餐厅信息删除接口
    # 饭局接口
    (r"/api/activities/add_activity", activities.AddActivity),  # 发布饭局接口
    (r"/api/activities", activities.Activities),  # 饭局列表接口
    (r"/api/activity/detail", activities.ActivityDetail),  # 饭局详情接口
    # 酒柜控制
    (r"/api/device_control/setup", device_control.Setup),  # 设备控制接口
    (r"/api/device_control/devicelist", device_control.DeviceList),  # 查看设备列表接口
    (r"/api/device_control/status", device_control.SaveDeviceStatus),  # 查看/保存设备状态接口
    (r"/api/device_control/set", device_control.SetDevice),  # 控制酒柜并获取设备最新状态
    # 线下门店
    (r"/api/store/mall", store.Mall),  # 线下商城接口
    (r"/api/store/list", store.StoreList),  # 门店列表/搜索接口
    (r"/api/store/cart", store.Cart),  # 门店购物车接口
    (r"/api/store/detail/(\w+)", store.GoodsDetail),  # 门店商品详情接口
    (r"/api/store/payconfirm", store.PayConfirm),  # 订单确认接口
    (r"/api/store/wechat_notify", store.WechatNotify),  # 微信支付回调接口
    (r"/api/store/account", store.UserAccount),  # 个人中心
    (r"/api/store/order", store.Order),  # 订单列表接口
    (r"/api/store/order/detail/(\w+)", store.OrderDetail),  # 门店订单详情接口
    (r"/api/store/buy_part", store.BuyPartGoods),  # 选中购物车中部分商品购买
    (r"/api/store/receive_coupon", store.ReceiveCoupon),  # 领取139优惠券
    (r"/api/store/coupons", store.Coupons),  # 优惠券列表接口
    (r"/api/store/order_status/callback", store.OrderStatusCallback),  # 美团配送订单状态回调接口
    (
        r"/api/store/order_exception/callback",
        store.OrderExceptionCallback,
    ),  # 美团配送订单异常回调接口
    (r"/api/store/area/callback", store.AreaCallback),  # 美团配送门店范围变更回调接口
    (
        r"/api/store/delivery_risk_level/callback",
        store.DeliveryRiskLevelCallback,
    ),  # 美团配送风险等级变更回调接口
    (r"/api/store/area", store.Area),  # 获取门店配送范围接口
    (r"/api/store/test/create/order", store.TestCreateOrder),  # 创建美团测试订单接口
    (r"/api/store/check", store.ShopCheck),  # 门店配送能力校验接口
    (r"/api/store/get/rider_location", store.GainRiderLocation),  # 获取美团骑手位置接口
    (r"/api/store/comment/product", store.CommentProduct),  # 评价商品接口
    (r"/api/store/goods_comments", store.GoodsComments),  # 商品评价列表接口
    (r"/api/store/comment/delete", store.DeleteComments),  # 商品评价删除接口
    (r"/api/store/upvote", store.CommentUpvote),  # 商品评价点赞接口
    (r"/api/store/available_coupons", store.AvailableCoupons),  # 获取可用优惠券接口
    # 门店后台
    (r"/api/admin/store/order", admin.Order),  # 门店后台订单列表接口
    (r"/api/admin/store/order_numbers", admin.OrderNumbers),  # 门店后台订单数接口
    (r"/api/admin/store/estimate/benefit", admin.EstimateBenefit),  # 查看待结算收益接口
    (r"/api/admin/store/manage/goods", admin.ManageGoods),  # 门店后台管理商品接口
    (r"/api/admin/store/account", admin.StoreAccount),  # 门店账号中心
    (r"/api/admin/store/register", admin.Register),  # 门店/店员注册
    (r"/api/admin/store/set_clerk", admin.SetClerk),  # 店长设置
    (r"/api/admin/store/clerk", admin.StoreClerk),  # 店员列表接口
    (r"/api/admin/store/printer/setup", admin.PrinterSetup),  # 打印机设置接口
    (r"/api/admin/store/printer/test", admin.PrinterTest),  # 打印机测试接口
    # 供应商后台
    (r"/api/admin/supplier/order", admin.Order),  # 订单列表接口
    (r"/api/admin/supplier/order_numbers", admin.OrderNumbers),  # 订单数接口
    (r"/api/admin/supplier/estimate/benefit", admin.EstimateBenefit),  # 查看待结算收益接口
    (r"/api/admin/supplier/manage/goods", admin.ManageGoods),  # 管理商品接口
    (r"/api/admin/supplier/account", admin.StoreAccount),  # 账号中心
    (r"/api/admin/supplier/register", admin.Register),  # 门店/店员注册
    (r"/api/admin/supplier/set_leader", admin.SetClerk),  # 店长设置
    (r"/api/admin/supplier/clerk", admin.StoreClerk),  # 店员列表接口
    (r"/api/admin/supplier/printer/setup", admin.PrinterSetup),  # 打印机设置接口
    (r"/api/admin/supplier/printer/test", admin.PrinterTest),  # 打印机测试接口
    (r"/api/admin/supplier/courier", admin.Courier),  # 快递物流公司列表接口
    (r"/api/admin/supplier/pickup", admin.Courier),  # 供应商发货申请
    (r"/api/admin/supplier/order/shipped", partner.OrderShipped),  # 供应商确认发货
    # 礼品卡相关接口
    (r"/api/gift/code_check", gift.CodeCheck),  # 口令校验接口
    (r"/api/gift/receive_gift", gift.ReceiveGift),  # 礼品卡订单领取接口
    (r"/api/gift/pwd_check", gift.PasswordCheck),  # 员工卡口令校验接口
    (r"/api/gift/info", gift.GiftInfoHandler),  # 员工卡口令校验接口
    (r"/api/gift/receive", gift.ReceiveGiftHandler),  # 礼品订单领取接口
    (r"/api/gift/application", gift.GiftApplication),  # 申领礼品酒杯接口
    # 发现
    (r"/api/discover/upload_img", discover.UploadImg),  # 图片上传接口
    (r"/api/discover/create_posts", discover.CreatePosts),  # 发布贴子接口
    (r"/api/discover/posts", discover.Posts),  # 贴子列表接口
    (r"/api/discover/posts/upvote", discover.PostsUpvote),  # 点赞与取消点赞接口
    (r"/api/discover/posts/create_comment", discover.CreateComment),  # 添加评论接口
    (r"/api/discover/posts/detail", discover.PostsDetail),  # 帖子详情接口
    (r"/api/discover/posts/comments", discover.PostsComments),  # 帖子评论列表接口
    (r"/api/discover/posts/mongo_handle", discover.MongoHandle),  # 清空帖子集合并创建索引
    (r"/api/discover/posts/user_posts", discover.UserPosts),  # 查看用户自己发布的帖子列表接口
    (r"/api/discover/posts/delete", discover.DeletePosts),  # 帖子删除接口
    (r"/api/discover/upload_resource", discover.UploadResource),  # 文件上传接口
    (r"/api/discover/write_article", discover.WriteArticle),  # 发布文章接口
    (r"/api/discover/article", discover.Article),  # 文章列表接口
    (r"/api/discover/collect", discover.CollectArticle),  # 收藏与取消收藏接口
    (r"/api/discover/subscribe", discover.Subscribe),  # 关注与取消关注接口
    (r"/api/discover/test", discover.Test),  # 测试media_id接口
    (r"/api/discover/upload", discover.Upload),  # 获取公众号素材并上传到云存储
    (r"/api/discover/goods", discover.GoodsInfo),  # 获取推荐商品列表
    (r"/api/discover/fans", discover.Fans),  # 粉丝列表
    (r"/api/discover/focus", discover.Focus),  # 关注列表接口
    (r"/api/discover/account", discover.Account),  # 个人账号接口
    # 新饭局
    (r"/api/dinner/create_party", dinner.CreateParty),  # 发布饭局接口
    (r"/api/dinner/user_party", dinner.UserParty),  # 查看用户自己发布的饭局列表接口
    (r"/api/dinner/party", dinner.Party),  # 饭局列表接口
    (r"/api/dinner/create_index", dinner.CreateIndex),  # 创建索引接口
    (r"/api/dinner/upvote", dinner.PartyUpvote),  # 点赞与取消点赞接口
    (r"/api/dinner/join", dinner.PartyJoin),  # 加入与取消加入饭局接口
    (r"/api/dinner/create_comment", dinner.CreateComment),  # 发表评论接口
    (r"/api/dinner/detail", dinner.PartyDetail),  # 饭局详情接口
    (r"/api/dinner/comments", dinner.PartyComments),  # 饭局评论列表接口
    (r"/api/dinner/delete", dinner.DeleteParty),  # 删除饭局接口
    # 日志接口
    (r"/api/log", log.Logger),  # 前端日志接口
]
